var app = getApp(),
  $ = require("../../utils/httpHelper.js");
var address = require('../../utils/city.js')

Page({

  data: {
    height:0,
    username:'',
    phone:''
  },
  onShareAppMessage: function (res) {
    app.shareApp(res)
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          height: res.windowHeight
        })
      }
    });
  },


 
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
 
  inputuser(e){
    this.setData({
      username: e.detail.value
    })
  },
  inputphone(e){
    this.setData({
      phone: e.detail.value
    })
  },

  tomember(){
    console.log(this.data.username)
    var rd_session = wx.getStorageSync('rd_session');
    if (!app.check_empty(this.data.username) && !app.check_empty(this.data.phone)){
      if (app.checkPhone(this.data.phone)) {
        $.httpPost("applay_card", { name: this.data.username, phone: this.data.phone, rd_session: rd_session }, (data, err) => {
          if (data.result == "success") {
            //去支付

            app.wxpay_card(data.data.order_no, app.globalData.userInfo.openId);


          } else {
            wx.showToast({
              title: data.message
            })
          }
        })
      }else{
        wx.showToast({
          title: '手机格式不对哦！~',
          duration: 2000
        })
      }
      
    } else {
      wx.showToast({
        title: '有信息没有填写哦~',
        duration: 2000
      })
    }
    
  }

})
